﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B.X.Rabbit.ErrorCode
{
    public class ApiResult
    {
        /// <summary>
        /// 是否成功
        /// </summary>
        public bool IsSuc { get; private set; }
        /// <summary>
        /// 返回的消息
        /// </summary>
        public string Message { get; private set; }
        /// <summary>
        /// 接口请求结果的状态码
        /// </summary>
        public ResultCode Code { get; private set; }
        protected internal ApiResult(bool isSuc, string message, ResultCode code)
        {
            IsSuc = isSuc;
            Message = message;
            Code = code;
        }
        /// <summary>
        /// 成功的返回结果
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public static ApiResult Success(ResultCode code)
        {
            return new ApiResult(true, "操作成功", code);
        }
        /// <summary>
        /// 失败的返回结果
        /// </summary>
        /// <param name="reason"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public static ApiResult Error(string reason, ResultCode code)
        {
            return new ApiResult(false, reason, code);
        }
    }
}
